
clear all

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"
local path1="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\outregs"

capture cd "`path0'Workfiles"
set more off
use completed_data, clear



	* create settler mortality with the African data corrected based on Albouy
	capture drop logmort3
	gen logmort3=logmort2
	replace logmort3=logmort if countrycode=="SGP" | countrycode=="AUS"
	
	gen lnUKdist=log(geo_UK_distw)


	*** regress RISK on IDV
	xi: reg icrg_ERR_mean idv if logmort~=. & distM_UK~=., robust
	outreg2 idv  using "`path1'\RR_table006A.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: idv only") 
		
	xi: ivreg2 icrg_ERR_mean (idv=distM_UK) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 idv  using "`path1'\RR_table006A.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		

	xi: ivreg2 icrg_ERR_mean i.continent (idv=distM_UK) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 idv  using "`path1'\RR_table006A.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + cont") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	
	xi: ivreg2 icrg_ERR_mean landlocked abs_long abs_lati (idv=distM_UK) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 idv  using "`path1'\RR_table006A.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + muslim") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	xi: ivreg2 icrg_ERR_mean landlocked abs_long abs_lati i.continent (idv=distM_UK) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 idv  using "`path1'\RR_table006A.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + all") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`	
	*** regress IDV on RISK	
	xi: reg idv icrg_ERR_mean  if logmort~=. & distM_UK~=. , robust
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006B.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: idv only") 
		
	xi: ivreg2 idv (icrg_ERR_mean=logmort) if logmort~=.  & pwt_ln_rgdpwok~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006B.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		

	xi: ivreg2 idv i.continent (icrg_ERR_mean=logmort) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean using "`path1'\RR_table006B.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + cont") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	
	xi: ivreg2 idv landlocked abs_long abs_lati (icrg_ERR_mean=logmort) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006B.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + muslim") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	xi: ivreg2 idv landlocked abs_long abs_lati i.continent (icrg_ERR_mean=logmort) if logmort~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006B.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + all") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	
	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`	
	*** regress IDV on RISK	
	*** Use Albouy's data for African countries
	
	xi: reg idv icrg_ERR_mean  if logmort3~=. & distM_UK~=. , robust
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006C.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: idv only") 
		
	xi: ivreg2 idv (icrg_ERR_mean=logmort3) if logmort~=. & pwt_ln_rgdpwok~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006C.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		

	xi: ivreg2 idv i.continent (icrg_ERR_mean=logmort3) if logmort~=. & pwt_ln_rgdpwok~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean using "`path1'\RR_table006C.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + cont") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	
	xi: ivreg2 idv landlocked abs_long abs_lati (icrg_ERR_mean=logmort3) if logmort~=. & pwt_ln_rgdpwok~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006C.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + muslim") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	xi: ivreg2 idv landlocked abs_long abs_lati i.continent (icrg_ERR_mean=logmort3) if logmort~=. & pwt_ln_rgdpwok~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]	
	outreg2 icrg_ERR_mean  using "`path1'\RR_table006C.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV + all") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
